package main

import "fmt"

// 接口的实现

type animal interface {
	move()
	eat(something string)
}

type cat struct {
	name string
	feet int8
}

type zhizhen struct {
	name string
	feet int8
}

// 值接受者
func (c cat) move() {
	fmt.Println("猫动")
}

func (c cat) eat(foot string) {
	fmt.Println("猫吃:", foot)
}

type chicken struct {
	feet int8
}

func (c chicken) move() {
	fmt.Println("鸡动")
}

func (c chicken) eat(foot string) {
	fmt.Println("鸡吃", foot)
}

func (c *zhizhen) move() {
	fmt.Println("鸡动")
}

func (c *zhizhen) eat(foot string) {
	fmt.Println("鸡吃", foot)
}

func main() {
	var a1 animal // 定义一个接口类型的1变量
	bc := cat{    // 定义一个cat类型的变量bc
		name: "tom",
		feet: 4,
	}
	a1 = bc
	a1.eat("鱼")
	fmt.Println(a1)

	kfc := chicken{
		feet: 2,
	}
	a1 = kfc
	a1.eat("玉米")
	fmt.Println(a1)

	c1 := zhizhen{"tom", 4} // cat
	c2 := zhizhen{"假老练", 4} //* cat
	a1 = &c1
	a1 = &c2
}

// 嵌套
type animals interface {
	moves
	eater
}

// 同一个结构体可以实现多个接口

type mover interface {
	moves()
}

type eater struct {
	eater (string)
}

func (c *cat) moves() {

}

func (c *cat) eater() {

}
